import Cookies from 'js-cookie'

// Token
const tokenKey = 'token'
export const getToken = () => Cookies.get(tokenKey)
export const setToken = (token: string) => Cookies.set(tokenKey, token)
export const removeToken = () => Cookies.remove(tokenKey)

// User Info
const userInfoKey = 'userInfo'
export const getUserInfo = () => {
  const userInfo = Cookies.get(userInfoKey)
  return userInfo ? JSON.parse(userInfo) : null
}
export const setUserInfo = (userInfo: any) => Cookies.set(userInfoKey, JSON.stringify(userInfo))
export const removeUserInfo = () => Cookies.remove(userInfoKey)

// 清除所有认证信息
export const clearAuth = () => {
  removeToken()
  removeUserInfo()
} 